/**
 * @author aherbertz
 * @created 07.09.2005
 * $Id$
 */
package de.herberlin.htmlspecialchar;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.HeadlessException;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;

/**
 * TODO: comment me!
 *
 * @author aherbertz
 * @since 07.09.2005
 * @version $Id$
 */
public class Main extends JFrame {

	private JTextArea area=null;
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * @throws HeadlessException
	 */
	public Main() throws HeadlessException {
		super("HtmlSpecialChars");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		Container c = this.getContentPane();
		c.setLayout(new BorderLayout());
		area = new JTextArea();
		c.add(new JScrollPane(area), BorderLayout.CENTER);
		area.setLineWrap(true);
		area.setFont(new Font("Monospaced", Font.PLAIN, 12));
		area.setWrapStyleWord(true);
		area.addFocusListener(new FocusAdapter() {
			public void focusGained(FocusEvent e) {
				area.setText("");
				area.paste();
				area.setText(HTMLSpecialCharacters.encode(area.getText()));
				area.selectAll();
				area.copy();
			}
		});
		this.setSize(320, 240);
		this.setVisible(true);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new Main();

	}

}
